package com.smartboot.plus.controller;


import com.smartboot.plus.api.R;
import com.smartboot.plus.dto.UserDTO;
import com.smartboot.plus.service.MqttUserService;
import com.smartboot.plus.vo.MqttUserVO;
import tech.smartboot.feat.cloud.annotation.Autowired;
import tech.smartboot.feat.cloud.annotation.Controller;
import tech.smartboot.feat.cloud.annotation.RequestMapping;
import tech.smartboot.feat.core.server.Session;

import java.io.IOException;

/**
 * 登录
 */
@Controller
public class LoginController {


    @Autowired
    private MqttUserService mqttUserService;

    /**
     * 登录
     */
    @RequestMapping("/auth/login")
    public R<MqttUserVO> login(Session session, UserDTO userDTO) throws IOException {
        return R.data(mqttUserService.login(session, userDTO));
    }


    @RequestMapping("/auth/codes")
    public R<Object> codes() {
        return R.data(mqttUserService.codes());
    }

    /**
     * 获取用户信息
     */
    @RequestMapping("/user/info")
    public R<Object> info() {
        return R.data(mqttUserService.info());
    }

    /**
     * 退出
     *
     * @param session
     */
    @RequestMapping("/auth/logout")
    public R<Object> logout(Session session) {
        return R.status(mqttUserService.logout(session));
    }



}
